<?php

namespace app\qsapi\model;

use think\Exception;

class BoxLoginLog extends BaseModel
{

// 直接使用配置参数名; 数据库连接配置;用与连接哪个数据库
    protected $connection = 'Db_log';

    /**
     * 查询当日日志
     * @param $date
     * @return BoxLoginLog[]|\think\Collection
     */
    public function getLoginLog($date){
        $startTime = $date . " 00:00:00";
        $endTime = $date . " 23:59:59";
        return $this->field(['member_id', 'reg_time', 'ctime'])->where([['ctime', 'between', [$startTime, $endTime]]])->select();
    }

    /**
     * 创建登录日志
     * @param $data
     * @return bool
     */
    public function createLoginLog($data): bool
    {
        try {
            if (empty($data)) {
                return false;
            }
            return $this->insert($data);
        }catch (Exception $e){
            return false;
        }
    }

}